<template>
  <div class="count">
    <h2>当前求和为{{ countStore.sum }}</h2>
    <!-- v-model将选择框的选中值与 Vue 实例中的 n 数据属性进行绑定 -->
    <!-- 将收集到的数据尽量转为number -->
    <select v-model.number="n">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
    <button @click="add()">加</button>
    <button @click="reduce()">减</button>
  </div>
</template>

<script setup lang="ts" name="Count">
import { ref, reactive } from "vue";
import { useCountStort } from "@/store/count";

const countStore = useCountStort();
console.log("@", countStore.sum);

//reactive中的ref被自动拆包  使用的时候不用.value
// let obj = reactive({
//   a: 1,
//   b: ref(3),
// });
// console.log(obj.a);
// console.log(obj.b);

let n = ref(1);

function add() {}
function reduce() {}
</script>

<style scoped>
.count {
  background-color: skyblue;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 0 10px;
}

select,
button {
  margin: 0 5px;
  height: 30px;
}
</style>
